package tests;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import exceptions.InvalidItemCategoryException;
import exceptions.InvalidItemNameException;
import exceptions.InvalidUserAddress;
import exceptions.InvalidUserName;
import exceptions.InvalidUserUsername;

import root.item.GerenciadorItem;
import root.user.User;
import strategy.AbstractStrategyFactory;
public class ItemManagerTest {
	
	User user;
	final String name = "blabla";
	final String description = "blabla";
	final String username = "testclass";
	final String email = "test@test.com";
	final String address = "oi";
	String id;;
	private GerenciadorItem manager;
	
	@Before
	public void setUp() throws InvalidUserUsername, InvalidUserName, InvalidUserAddress, InvalidItemNameException, InvalidItemCategoryException{
		user = new User(username, name, address,AbstractStrategyFactory.getInstance());
		manager = new GerenciadorItem();
		id = manager.addItem(user, name, description, "Livro");
	}
	
	@Test
	public void testCreateItem(){
		assertTrue(manager.hasItem(id));
	}
	
	@Test(expected=InvalidItemNameException.class)
	public void testCreateItem2() throws InvalidItemNameException, InvalidItemCategoryException{
		user.addItem(user, null, description, "Livro");
	}
	
	@Test(expected=NullPointerException.class)
	public void testCreateItem3() throws InvalidItemNameException, InvalidItemCategoryException{
		user.addItem(user, name, null, "Livro");
	}
	
	@Test(expected=InvalidItemCategoryException.class)
	public void testCreateItem4() throws InvalidItemNameException, InvalidItemCategoryException{
		user.addItem(user, name, description, null);
	}
	
	@Test(expected=InvalidItemCategoryException.class)
	public void testCreateItem5() throws InvalidItemNameException, InvalidItemCategoryException{
		user.addItem(user, name, description, "xpto");
	}
	
	@Test(expected=NullPointerException.class)
	public void testCreateItem6() throws InvalidItemNameException, InvalidItemCategoryException{
		user.addItem(null, name, description, "Livro");
	}
	
}
